package models

import (
	"fmt"
	"log"
	"my-crawler/database/mysql"
	"strconv"
)

type QueryData struct {
	ID       int
	ASECCODE string `db:"ASECCODE"`
}

func GetModels(id string) (map[string]string, map[string]string, string) {
	var DB = mysql.Db
	var result []QueryData
	err := DB.Select(&result,
		"select id,ASECCODE from 2022_juchao where  id > "+id+" limit 1")

	if err != nil || len(result) < 1 {
		log.Println("exec failed1, ", err)
	}
	fmt.Println(result)
	m := make(map[string]string)

	m["scode"] = result[0].ASECCODE
	m["id"] = strconv.Itoa(result[0].ID)
	//拼url
	var reqUrl = "http://www.cninfo.com.cn/data20/companyOverview/getCompanyIntroduction"

	//Cookie 也是需要变
	header := map[string]string{
		"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6304051b)",
		"Cookie":     "rewardsn=; wxtokenkey=777; wxuin=96172675; devicetype=Windows10x64; version=6304051b; lang=zh_CN; pass_ticket=gXAcku+ORLS4hanpApor2EB+SsPifsGSbWATi2IyLpo0Pb3OxEkftP+CLAqpk/FO; appmsg_token=1150_qoZzJolSGIJQMeBSfjJCFHDi2EQRCi0rIvuRTyuOmblZOVf0dv2XdKBVTck~; wap_sid2=CIP17S0SigF5X0hLSGVpUjJTNDhXV2tVOUt5djltc0pMdFVGRmlYdzVQNGpBN18wQzQzVWNZR1VoamVqQ0YtM0NYV2ZKbWxsajdFR1U4Zlp0UUVxRU1xTGRfRTB6a016T2l6UUJ3MXduNkZEdUJUa2d6bFFmU0hCRDN4a3VaQjRkWHN1Qk9uOEJwNFZzU0FBQX4wi5LNjwY4DUAB",
	}
	return m, header, reqUrl
}
